home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / ex / ex8-15.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  1KB  |  36 lines

  1. // ex8-15.c -- Comparison of classes Dictionary and IdentDict
  2.  
  3. // $Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/ex8-15.c,v 3.0 90/05/15 22:46:11 kgorlen Rel $
  4.  
  5. #include "Dictionary.h"
  6. #include "IdentDict.h"
  7. #include "LookupKey.h"
  8. #include "String.h"
  9. #include "SortedCltn.h"
  10.  
  11. main()
  12. {
  13.     String s1 = "A String";
  14.  
  15.     Dictionary d;
  16.     d.addAssoc(s1,*new String("value associated with s1"));
  17.     cout << "Dictionary:" << endl;
  18.     LookupKey* lk = d.assocAt(String("A String"));
  19.     if (lk) cout << *lk->value() << endl;
  20.     else cout << "Not found" << endl;
  21.     lk = d.assocAt(s1);
  22.     if (lk) cout << *lk->value() << endl;
  23.     else cout << "Not found" << endl;
  24.     cout << endl;
  25.  
  26.     IdentDict i;
  27.     i.addAssoc(s1,*new String("value associated with s1"));
  28.     cout << "IdentDict:" << endl;
  29.     lk = i.assocAt(String("A String"));
  30.     if (lk) cout << *lk->value() << endl;
  31.     else cout << "Not found" << endl;
  32.     lk = i.assocAt(s1);
  33.     if (lk) cout << *lk->value() << endl;
  34.     else cout << "Not found" << endl;
  35. }
  36.